<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container{
            display: flex;
            width: 500px;height: 300px;
            border: 1px solid red;
            flex-direction: row;
            justify-content: flex-start;
  align-items: stretch;flex-wrap: wrap-reverse;
        }
        .item{
            width: 100px;
            background-color: blue;display: flex;margin: 5px;
        }
        span{
            margin: auto;
        }
    </style>
    </style>
</head>
<body>
    <div class="container">
        <div class="item"><span>1</span></div>
        <div class="item"><span>2</span></div>
        <div class="item"><span>3</span></div>
        <div class="item"><span>4</span></div>

        <div class="item"><span>5</span></div>
        <div class="item"><span>6</span></div>
        <div class="item"><span>7</span></div>
    </div>
</body>
</html>